﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<OneDollarStore.SerialProduct>>" %>

<% foreach (var item in Model)
   { %>
    <div class="item">
        <img src="<%= this.ResolveUrl("~/Images/Bordtop.png") %>" alt="" width="290" height="2" />
        <div>
            <% if (item.Category.Name.Equals("Laptop")) // Laptop product
               { %>
                <img src="<%= this.ResolveUrl("~/Images/Laptops/") + item.Image %>" alt="" width="100" height="90" />
                <h1><%= Html.Encode(item.Name)%></h1>
                <span><%= Html.Encode(item.Laptop.RAM)%></span>
            <% }
               if (item.Category.Name.Equals("Desktop")) // Desktop product
               { %>
                <img src="<%= this.ResolveUrl("~/Images/Desktops/") + item.Image %>" alt="" width="100" height="90" />
                <h1><%= Html.Encode(item.Name)%></h1>
                <span><%= Html.Encode(item.Desktop.RAM)%></span>
            <% }
               if (item.Category.Name.Equals("Mainboard")) // Mainboard product
               { %>
                <img src="<%= this.ResolveUrl("~/Images/Mainboards/") + item.Image %>" alt="" width="100" height="90" />
                <h1><%= Html.Encode(item.Name)%></h1>
                <span><%= Html.Encode(item.Mainboard.Chipset)%></span>
            <% }
               if (item.Category.Name.Equals("CPU")) // CPU product
               { %>
                <img src="<%= this.ResolveUrl("~/Images/CPUs/") + item.Image %>" alt="" width="100" height="90" />
                <h1><%= Html.Encode(item.Name)%></h1>
                <span><%= Html.Encode(item.CPU.Speed)%></span>
            <% }
               if (item.Category.Name.Equals("RAM")) // RAM product
               { %>
                <img src="<%= this.ResolveUrl("~/Images/RAMs/") + item.Image %>" alt="" width="100" height="90" />
                <h1><%= Html.Encode(item.Name)%></h1>
                <span><%= Html.Encode(item.RAM.Memory)%></span>
            <% }
               if (item.Category.Name.Equals("HDD")) // HDD product
               { %>
                <img src="<%= this.ResolveUrl("~/Images/HDDs/") + item.Image %>" alt="" width="100" height="90" />
                <h1><%= Html.Encode(item.Name)%></h1>
                <span><%= Html.Encode(item.HDD.Storage)%></span>
            <% }
               if (item.Category.Name.Equals("VGA")) // VGA product
               { %>
                <img src="<%= this.ResolveUrl("~/Images/VGAs/") + item.Image %>" alt="" width="100" height="90" />
                <h1><%= Html.Encode(item.Name)%></h1>
                <span><%= Html.Encode(item.VGA.VideoMemory)%></span>
            <% } %>    
                <p>
                    <% if (String.IsNullOrEmpty(item.PromotionPrice.ToString()) || 
                           ((!String.IsNullOrEmpty(item.PromotionPrice.ToString())) && (DateTime.Today > item.PromotionEndDate)))
                       { %>
                        <strong><%= String.Format("{0:c}", item.RetailPrice)%></strong>
                    <% }
                       else
                       { %>
                        <strong style="color:Purple; font-size:13px; text-decoration:line-through"><%= String.Format("{0:c}", item.RetailPrice)%></strong>
                        <br />
                        <strong><%= String.Format("{0:c}", item.PromotionPrice)%></strong>
                    <% } %>
                </p>
                <br style="clear:both" />
                <%= Ajax.ActionLink("Chi tiết", "Details", new { id = item.SerialProductID }, new AjaxOptions { UpdateTargetId = "details", OnSuccess = "hideLoading" }, new { @class = "details" })%>
                <%= Html.ActionLink("Mua", "AddToCart", "ShoppingCart", new { id = item.SerialProductID }, new { @class = "add-to-cart" })%>                
        </div>
        <img src="<%= this.ResolveUrl("~/Images/Bordbot.png") %>" alt="" width="290" height="2" />
    </div>
<% } %>